def select_second(L):
    """Return the second element of the given list. If the list has no second
    element, return None.
    """
    if len(L) > 1:
        return L[1]
    else:
        return None
    # if len(L) < 2:
    #     return None
    # return L[1]


def purple_shell(racers):
    """Given a list of racers, set the first place racer (at the front of the list) to last
    place and vice versa.

    >>> r = ["Mario", "Bowser", "Luigi"]
    >>> purple_shell(r)
    >>> r
    ["Luigi", "Bowser", "Mario"]
    """
    start = racers[0]
    racers[0] = racers[-1]
    racers[-1] = start


"""
a: There are three items in this list. Nothing tricky yet.
b: The list [2, 3] counts as a single item. It has one item before it. So we have 2 items in the list
c: The empty list has 0 items
d: The expression is the same as the list [2, 3], which has length 2.
"""
a = [1, 2, 3]
b = [1, [2, 3]]
c = []
d = [1, 2, 3][1:]

# Put your predictions in the list below. Lengths should contain 4 numbers, the
# first being the length of a, the second being the length of b and so on.
lengths = [3, 2, 0, 2]

"""
We're using lists to record people who attended our party and what order they arrived in. 
For example, the following list represents a party with 7 guests, 
in which Adela showed up first and Ford was the last to arrive:

party_attendees = ['Adela', 'Fleda', 'Owen', 'May', 'Mona', 'Gilbert', 'Ford']
A guest is considered 'fashionably late' if they arrived after at least half of the party's guests. 
However, they must not be the very last guest (that's taking it too far). 
In the above example, Mona and Gilbert are the only guests who were fashionably late.

Complete the function below which takes a list of party attendees as well as a person, 
and tells us whether that person is fashionably late.
"""


def fashionably_late(arrivals, name):
    """Given an ordered list of arrivals to the party and a name, return whether the guest with that
    name was fashionably late.
    """
    order = arrivals.index(name)
    return order >= len(arrivals) / 2 and order != len(arrivals) - 1
    # middle = int(len(arrivals) / 2)
    # target_person = arrivals[middle: -1]
    # return name in target_person


# print(fashionably_late(['Paul', 'John', 'Ringo', 'George'], name='Ringo'))
print(fashionably_late(arrivals=['Adela', 'Fleda', 'Owen', 'May', 'Mona', 'Gilbert', 'Ford'], name='May'))
